/*
OpenMVL Matrix Vector Library
Copyright (c) 2009 FluidInteractive (R)
 
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising
from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
 
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
 
Written by: Nicola Candussi <nicola@fluidinteractive.com>
*/

//promote_traits.hpp

#ifndef MVL_PROMOTE_TRAITS_HPP
#define MVL_PROMOTE_TRAITS_HPP

#include "type_traits.hpp"

namespace mvl {

template<typename T1, typename T2> 
struct promote_traits {

    typedef typename meta::is_floating_point<T1>::type t1_fp;
    typedef typename meta::is_floating_point<T2>::type t2_fp;

    //promote to floating point if necessary
    typedef typename meta::if_<
        typename meta::and_<
            typename meta::not_<t1_fp>::type,
            t2_fp>
        ::type,
        T2,
        T1
    >::type t1_1;

    typedef typename meta::if_<
        typename meta::and_<
            typename meta::not_<t2_fp>::type,
            t1_fp
        >::type,
        T1,
        T2
    >::type t2_1;

    //pick the bigger size
    typedef typename meta::if_<
        meta::bool_<(sizeof(t1_1) > sizeof(t2_1))>,
        t1_1,
        t2_1
    >::type promote_t;
        
   // typedef T1 promote_t;
};

} // namespace mvl

#endif
